﻿namespace Jhong.FunMVCBlog.Core.Data
{
    using Entity;

    public class BlogSysData : BaseData
    {
        private void Set(string key, string value)
        {
            using (this._dbContext)
            {
                this._dbContext.T("update blog_sys set SysValue=@1 where SysKey=@0", key, value).Execute();
            }
        }

        private BlogSys Get(string key)
        {
            using (this._dbContext)
            {
                return this._dbContext.T("SELECT * from blog_sys where SysKey=@0", key).QueryFirstOrDefault<BlogSys>();
            }
        }

        public string GetAccount()
        {
            return this.Get("Account").SysValue;
        }

        public string GetPassword()
        {
            return this.Get("Password").SysValue;
        }

        public void SetPassword(string pwd)
        {
            this.Set("Password", pwd);
        }

        public void SetAccount(string account)
        {
            this.Set("Account", account);
        }

        public string GetPersonThumbnail()
        {
            return this.Get("PersonThumbnail").SysValue;
        }

        public void SetPersonThumbnail(string path)
        {
            this.Set("PersonThumbnail", path);
        }

        public string GetNickName()
        {
            return this.Get("NickName").SysValue;
        }

        public void SetNickName(string name)
        {
            this.Set("NickName", name);
        }

        public void SetBlogName(string name)
        {
            this.Set("BlogName", name);
        }

        public string GetBlogName()
        {
            return this.Get("BlogName").SysValue;
        }

        public string GetAbout()
        {
            return this.Get("About").SysValue;
        }

        public void SetAbout(string about)
        {
            this.Set("About", about);
        }

        public string GetHomePage()
        {
            return this.Get("HomePage").SysValue;
        }

        public void SetHomePage(string homepage)
        {
            this.Set("HomePage", homepage);
        }

    }
}